package service

import (
	"context"
	"douyin/biz/pb"
)

func (s *Service) RegisterUser(ctx context.Context, req *pb.DouyinUserRegisterRequest) (resp *pb.DouyinUserRegisterResponse, err error) {
	var (
		status = 0
		msg    = ""
	)
	userid, err := s.dao.InsertUser(ctx, req.Username, req.Password)

	if err != nil {
		status = 1
		msg = err.Error()
	}

	resp = &pb.DouyinUserRegisterResponse{
		StatusCode: int32(status),
		UserId:     uint64(userid),
		StatusMsg:  msg,
		Token:      req.Username + req.Password,
	}

	return
}
